import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home/index',
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    children: [
      {
        path: 'index',
        name: '/home/index',
        component: () => import('../views/Index.vue'),
        meta: {
          breadcrumbs: ['首页'],
        },
      },
      {
        path: 'commodity-list',
        name: '/home/commodity-list',
        component: () => import('../views/commodity/CommodityList.vue'),
        meta: {
          // 在此自定义一个meta数据，保存当前路由应显示的面包屑导航列表
          breadcrumbs: ['商品管理', '商品列表'],
        },
      },
      {
        path: 'commodity-add',
        name: '/home/commodity-add',
        component: () => import('../views/commodity/CommodityAdd.vue'),
        meta: {
          breadcrumbs: ['商品管理', '添加商品'],
        },
      },
      {
        path: 'order-list',
        name: '/home/order-list',
        component: () => import('../views/order/OrderList.vue'),
        // meta称为路由对象的元数据，在此处可以自定义配置一些路由相关参数
        // 方便在组件中使用
        meta: {
          // 在此自定义一个meta数据，保存当前路由应显示的面包屑导航列表
          breadcrumbs: ['订单管理', '订单列表'],
        },
      },
      {
        path: 'order-add',
        name: '/home/order-add',
        component: () => import('../views/order/OrderAdd.vue'),
        meta: {
          breadcrumbs: ['订单管理', '添加订单'],
        },
      },
      {
        path: 'address-list',
        name: '/home/address-list',
        component: () => import('../views/address/AddressList.vue'),
        meta: {
          breadcrumbs: ['地址管理', '地址列表'],
        },
      },
      {
        path: 'address-add',
        name: '/home/address-add',
        component: () => import('../views/address/AddressAdd.vue'),
        meta: {
          breadcrumbs: ['地址管理', '添加地址'],
        },
      },
      {
        path: 'estimate-list',
        name: '/home/estimate-list',
        component: () => import('../views/estimate/EstimateList.vue'),
        meta: {
          breadcrumbs: ['评价管理', '评价列表'],
        },
      },
      {
        path: 'estimate-add',
        name: '/home/estimate-add',
        component: () => import('../views/estimate/EstimateAdd.vue'),
        meta: {
          breadcrumbs: ['评价管理', '添加评价'],
        },
      },
      {
        path: 'account-list',
        name: '/home/account-list',
        component: () => import('../views/account/AccountList.vue'),
        meta: {
          breadcrumbs: ['账户管理', '账户列表'],
        },
      },
      {
        path: 'account-add',
        name: '/home/account-add',
        component: () => import('../views/account/AccountAdd.vue'),
        meta: {
          breadcrumbs: ['账户管理', '添加账户'],
        },
      },
    ],
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue'),
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router
